﻿using System.IO;
using System.Xml.Serialization;

namespace NRadioTray.App.Domain
{
    public static class PlaylistHelper
    {
        public static void SerializeToXml<T>(T obj, string path)
        {
            XmlSerializer xs = new XmlSerializer(typeof(T));
            using (FileStream fs = File.Create(path))
            {
                xs.Serialize(fs, obj);
            }
        }

        public static T DeserializeFromXml<T>(string path)
        {
            XmlSerializer xs = new XmlSerializer(typeof(T));
            using (FileStream fs = File.OpenRead(path))
            {
                return (T)xs.Deserialize(fs);
            }
        }
    }
}
